package com.yuchen.ishop.service.seller;

import com.yuchen.core.MyPager;
import com.yuchen.ishop.entity.SellerXiaoer;
import com.yuchen.jaxrs.Responses;
import com.yuchen.jaxrs.restclient.RestClientUtils;
import com.yuchen.utils.config.ConfigUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 *
 */
@Service
public class XiaoerRestClient {

    public SellerXiaoer insertXiaoer(SellerXiaoer sellerXiaoer) {
        String url = ConfigUtils.config.get("sellerXiaoer_insert");
        return RestClientUtils.post(SellerXiaoer.class, sellerXiaoer, url);
    }

    public Responses deleteXiaoer(Long id) {
        String url = ConfigUtils.config.get("sellerXiaoer_delete");
        Map map = new HashMap(1);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.delete(Responses.class, url);
    }

    public MyPager findXiaoers(Map cnds) {
        String url = ConfigUtils.config.get("sellerXiaoer_find");
        return RestClientUtils.post(MyPager.class, cnds, url);
    }

    public Responses existXiaoer(Long sellerId, Long id) {
        String url = ConfigUtils.config.get("sellerXiaoer_exist");
        Map map = new HashMap(2);
        map.put("sellerId", sellerId);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(Responses.class, url);
    }

    public SellerXiaoer getXiaoer(Long id) {
        String url = ConfigUtils.config.get("sellerXiaoer_get");
        Map map = new HashMap(1);
        map.put("id", id);
        url = RestClientUtils.url(url, map);
        return RestClientUtils.get(SellerXiaoer.class, url);
    }

    public Responses updateXiaoer(SellerXiaoer xiaoer) {
        String url = ConfigUtils.config.get("sellerXiaoer_update");
        return RestClientUtils.post(Responses.class, xiaoer, url);
    }

    public Responses updatePwd(Map map) {
        String url = ConfigUtils.config.get("sellerXiaoer_updatePwd");
        return RestClientUtils.post(Responses.class, map, url);
    }
}
